<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output indent="yes" method="html"/>
        <xsl:variable name="msgCount" select="count(/RPCReply/*/com.transcargo.mail.MailHeader)"/>

        <xsl:template match="/*/com.transcargo.mail.MailHeader-array">
	    <b><h3>[<xsl:value-of select="/RPCReply/@folder"/>]</h3></b>Сообщений: <xsl:value-of select="$msgCount"/><br/>
	    <form name="delmail">

            <table width="60%" cellpadding="0" cellspacing="1" bgcolor="#000000">
                <thead><tr bgcolor="#DDDDDD">
                    <th>&#160;</th>
                    <th>Дата</th>
		    <xsl:choose>
		    <xsl:when test="/RPCReply/@folder='inbox'"><th>Отправитель</th></xsl:when>
			<xsl:otherwise><th>Получатель</th></xsl:otherwise>
		    </xsl:choose>
                    <th>&#160;</th>
                    <th>Тема</th>
                </tr></thead>
		<xsl:choose>
			<xsl:when test="$msgCount &gt; 0">
   			         <xsl:apply-templates select="com.transcargo.mail.MailHeader"/>
			</xsl:when>
			<xsl:otherwise>
                		<tr bgcolor="#FFFFFF"><td colspan="5" align="center">Новых сообщений нет</td></tr>
			</xsl:otherwise>
		</xsl:choose>
	    </table>
	    <xsl:if test="$msgCount &gt; 0"><input type="submit" value="Удалить" onclick="delmailProcess();return false;"/></xsl:if>
		
	    </form>

        </xsl:template>
        <xsl:template match="com.transcargo.mail.MailHeader">
        	<tr bgcolor="#ffffff">
			<td width="15"><input><xsl:attribute name="type">checkbox</xsl:attribute><xsl:attribute name="name">id<xsl:value-of select="id"/></xsl:attribute></input></td>
			<xsl:choose>
			<xsl:when test="read='false'">
				<td width="150"><b><a><xsl:attribute name="href">readmail.jsp?id=<xsl:value-of select="id"/></xsl:attribute><xsl:value-of select="date"/></a></b></td>
		    	<xsl:choose>
			<xsl:when test="/RPCReply/@folder='inbox'">
				<td><b><a><xsl:attribute name="href">company.jsp?id=<xsl:value-of select="sender/Id"/></xsl:attribute><xsl:value-of select="sender/name"/></a></b></td>
			</xsl:when><xsl:otherwise>
				<td><b><a><xsl:attribute name="href">company.jsp?id=<xsl:value-of select="recipient/Id"/></xsl:attribute><xsl:value-of select="recipient/name"/></a></b></td>
			</xsl:otherwise>
			</xsl:choose>
				<td><b><xsl:if test="priority='0'">Low</xsl:if><xsl:if test="priority='2'">High</xsl:if>&#160;</b></td>
				<td><b><a><xsl:attribute name="href">readmail.jsp?id=<xsl:value-of select="id"/></xsl:attribute><font><xsl:attribute name="color"><xsl:if test="priority='2'">#FF0000</xsl:if></xsl:attribute><xsl:value-of select="subject"/></font></a></b></td>
			</xsl:when>
			<xsl:otherwise>
				<td width="150"><a><xsl:attribute name="href">readmail.jsp?id=<xsl:value-of select="id"/></xsl:attribute><xsl:value-of select="date"/></a></td>
		    	<xsl:choose>
			<xsl:when test="/RPCReply/@folder='inbox'">
				<td><a><xsl:attribute name="href">company.jsp?id=<xsl:value-of select="sender/Id"/></xsl:attribute><xsl:value-of select="sender/name"/></a></td>
			</xsl:when><xsl:otherwise>
				<td><a><xsl:attribute name="href">company.jsp?id=<xsl:value-of select="recipient/Id"/></xsl:attribute><xsl:value-of select="recipient/name"/></a></td>
			</xsl:otherwise>
			</xsl:choose>
				<td><xsl:if test="priority='0'">Low</xsl:if><xsl:if test="priority='2'">High</xsl:if>&#160;</td>
				<td><a><xsl:attribute name="href">readmail.jsp?id=<xsl:value-of select="id"/></xsl:attribute><font><xsl:attribute name="color"><xsl:if test="priority='2'">#FF0000</xsl:if></xsl:attribute><xsl:value-of select="subject"/></font></a></td>
			</xsl:otherwise>
			</xsl:choose>
		</tr>
        </xsl:template>
</xsl:stylesheet>
